//
//  CZStatusReteew.swift
//  weibo27
//
//  Created by mac on 16/4/19.
//  Copyright © 2016年 it.cast. All rights reserved.
//

import UIKit

class CZStatusRetweeted: CZStatusCell {
    
    override var statusViewModel:CZStatusViewModel?{
        didSet{
            picture.snp_updateConstraints { (make) -> Void in
                // 根据配图数量，决定配图视图的顶部间距
                let offset = statusViewModel?.thumbnail_pic?.count > 0 ? StatusCellMargin : 0
                make.top.equalTo(retweetedLabel.snp_bottom).offset(offset)
            }
            
            retweetedLabel.text = statusViewModel?.retweenText
        }
    }
    
    /// 背景的按钮
    private lazy var backButton:UIButton = {
        
        let button = UIButton()
        
        button.backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        return button
    }()
    
    /// 转发标签
    
    private lazy var retweetedLabel = UILabel(title: "",
        fontSize: 14,
        color: UIColor.darkGrayColor(),
        screenInset: StatusCellMargin)
}


extension CZStatusRetweeted{
    
    override func setupUI() {
        
        super.setupUI()
        
        contentView.insertSubview(backButton, belowSubview: picture)
        contentView.insertSubview(retweetedLabel, aboveSubview: backButton)
        
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(textView.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        // 2> 转发标签
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top)
            make.left.equalTo(backButton.snp_left).offset(StatusCellMargin)
        }
        // 3> 配图视图
        picture.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(retweetedLabel.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }
    }
}














